classdef AbstractPort < handle
    %ABSTRACTPORT �˴���ʾ�йش����ժҪ
    %   �˴���ʾ��ϸ˵��
    
    properties
        device
        name
        type
    end
    
    properties
        last_setting
        current_setting
    end
    
    properties(Access=private)
        isZiPort
    end
    
    methods
        function obj = AbstractPort(device, name, type)
            p=inputParser;
            p.addRequired('device', @(x) isa(x, 'EquipmentControl.ZI.ziMFLI') || ...
                                         isa(x, 'EquipmentControl.SignalSource.TektronixAFG3252') || ...
                                         isa(x, 'EquipmentControl.SignalSource.RigolDG4202'));
            p.addRequired('name', @ischar);
            p.addRequired('type', @(x) ismember(x, {'input', 'output', 'bidirection'}));
            p.parse(device, name, type);

            obj.device = device;
            obj.name = [device.name '.' name];
            obj.type = type;
            
            obj.isZiPort = isa(obj.device, 'EquipmentControl.ZI.ziMFLI');
        end
    end
    
    %%
    methods
        function res = viewPortSignal(obj, varargin)
            getSession;
            zs = sess.getZIServer;
            
            scp = zs.scopeModule('scp');            
            scp.initialize();
            scp.setDevice('dev3560');
            scp.setSamplingRate(ziEnumScopeSamplingRate.Rate14_6kHz);
            scp.setDuration(0.1);
            scp.setMovingAverage(1);
            
            scp.setInput(ziScopeInput.AuxOut1).enableChannel(ziEnumTwoBitChoice.ONE);

            % scp.setTrigger(ziScopeTrigInput.OscPhi2, 'slope', ziEnumTrigEdgeSlope.Positive, 'level', 0);
            % scp.enableTrigger();
            
            scp.disableSegment().enableCh1BWLimit().enableCh2BWLimit();
            
            scp.setMode('time');
            res = scp.run('shot_number', 1, 'plot_window', 1);
            %
            % scp.setMode('frequency');
            % res = scp.run('shot_number', 200, 'plot_window', 2);
        end
    end
    
    %%
    methods(Abstract)        
        s = getCurrentSetting(obj)
        obj = recoverLastSetting(obj)
        obj = setup(obj, varargin)
        obj = initialize(obj)
    end
end

